const app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    typeGoodsList:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options.sortid);
    this.getTypeGoodsList(options.sortid);
  },
  getTypeGoodsList(typeId){
    wx.request({
      url: `${app.globalData.baseurl}category/${typeId}`,
      method: 'GET',
      success: (res) => {
        if (res.statusCode == 200) {
          this.setData({
            typeGoodsList: res.data
          });
          console.log(this.data.typeGoodsList);
        }
      },
      fail: (err) => {
        console.log('error!');
      }
    })
  },
  toGoodDetail(event){
    console.log(event.currentTarget.dataset.id);
    let id=event.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../../goodDetail/goodDetail?goodsId='+id,
    })
  },
})